package com.nova.android.tvlauncher.ui.service

import android.app.Service
import android.content.Intent
import android.os.IBinder
import com.nova.android.tvlauncher.JarLoader
import com.shudong.lib_base.ext.appContext

class DexLoaderService : Service() {

    override fun onCreate() {
        super.onCreate()
        try {
            val jarPath = "${appContext.filesDir.absolutePath}/lib_fat_dex.jar"
            JarLoader.initService(this, jarPath)
        } catch (e: Exception) {
            stopSelf()
        }
    }

    override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
        return try {
            JarLoader.onStartCommand(this, intent, flags, startId)
        } catch (e: Exception) {
            START_STICKY
        }
    }

    override fun onBind(intent: Intent?): IBinder? = null


}